<!DOCTYPE html>
<html>
<head>
<meta charset="UTF-8">
<title>Insert title here</title>
<script>

//재귀샘플 
	var walk_the_DOM = function walk(node,func){
		func(node);
		node = node.firstChild;
		while(node){
			walk(node,func);
			node  = node.nextSibling;
		}
	};
	
	var getElementsByAttribute = function(att,value){
		var results = [];
		var node = document.body;
		walk_the_DOM(node,function(){
			var actual = node.nodeType===1&&node.getAttribute(att);
			if(typeof actual==='string'&&(actual===value||typeof value  !=='string')){
				results.push(node);
				
			}
		});
		return results;
	}
	

	
	function pt(str){
		document.write("<br>"+str);
	}
	
	window.onload= function(e){
		var att = getElementsByAttribute("src");
		for(var i =0;i<att.length;i++){
			pt(att[i]);
		}
		
	}
</script>

</head>
<body>
<h1>Random Cat Pictures</h1>    
    <p>Lorem </p>
    <p>Etiam mattis </p>
    <p>Aenean justo.</p>
    <p>Maecenas bibe</p>
    <p>Etiam quam. Sed nisi. </p>    
    <ul class="gallery" title="Random Cat Pictures">
    	<li><a href="image1"><img src="../images/image1.jpg" alt="Fat Cat Sleeping"/></a></li>
    	<li><a href="image2"><img src="../images/image2.jpg" alt="Sharing the Bed"/></a></li>
    	<li class="tall"><a href="image3"><img src="../images/image3.jpg" alt="Out the Window"/></a></li>
    	<li class="tall"><a href="image4"><img src="../images/image4.jpg" alt="In the Sun"/></a></li>
    	<li><a href="image5"><img src="../images/image5.jpg" alt="Very Comfortable"/></a></li>
    </ul>    
</body>
</html>